Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
mimic-function
Advanced tools
Make a function mimic another one
Useful when you wrap a function in another function and you would like to preserve the original name and other properties.
npm install mimic-function
import mimicFunction from 'mimic-function';
function foo() {}
foo.unicorn = '🦄';
function wrapper() {
return foo();
}
console.log(wrapper.name);
//=> 'wrapper'
mimicFunction(wrapper, foo);
console.log(wrapper.name);
//=> 'foo'
console.log(wrapper.unicorn);
//=> '🦄'
console.log(String(wrapper));
//=> '/* Wrapped with wrapper() */\nfunction foo() {}'
Modifies the to
function to mimic the from
function. Returns the to
function.
name
, displayName
, and any other properties of from
are copied. The length
property is not copied. Prototype, class, and inherited properties are copied.
to.toString()
will return the same as from.toString()
but prepended with a Wrapped with to()
comment.
Type: Function
Mimicking function.
Type: Function
Function to mimic.
Type: object
Type: boolean
Default: false
Skip modifying non-configurable properties instead of throwing an error.
FAQs
Make a function mimic another one
The npm package mimic-function receives a total of 3,269,998 weekly downloads. As such, mimic-function popularity was classified as popular.
We found that mimic-function demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.